home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / Iomanip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-02  |  4.8 KB  |  168 lines

  1. #if __SC__ || __RCC__
  2. #pragma once
  3. #endif
  4.  
  5. #ifndef _IOMANIP_H_
  6. #define _IOMANIP_H_
  7.  
  8.  
  9. /*
  10.  *    iomanip.h -- streams I/O manipulator declarations
  11.  *
  12.  * $Id: iomanip.h,v 1.1.1.1 1997/01/02 19:16:41 smarx Exp $
  13.  *
  14.  ****************************************************************************
  15.  *
  16.  * Rogue Wave Software, Inc.
  17.  * P.O. Box 2328
  18.  * Corvallis, OR 97339
  19.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  20.  *
  21.  * Copyright (C) 1991,  1993, 1994.
  22.  * This software is subject to copyright protection under the laws of 
  23.  * the United States and other countries.
  24.  * ALL RIGHTS RESERVED
  25.  *
  26.  ***************************************************************************
  27.  *
  28.  * $Log: iomanip.h,v $
  29.  * Revision 1.1.1.1  1997/01/02 19:16:41  smarx
  30.  * cafe12
  31.  *
  32.  * 
  33.  *    Rev 1.4   24 May 1995 15:42:16   Andrew
  34.  * Fixed problem where structs/classes were not in pragma pack(__DEFALIGN)
  35.  * 
  36.  *    Rev 1.3   08 Oct 1994 14:11:56   BUSHNELL
  37.  * Added pragma once for faster compilations
  38.  * 
  39.  *    Rev 1.2   08 Oct 1994 10:11:34   BUSHNELL
  40.  * Added #include iostream.h for MS Compat
  41.  * 
  42.  *    Rev 1.1   02 Jun 1994 21:35:22   bushnell
  43.  * added ifdef so that MS RC will not include header twice
  44.  * 
  45.  
  46.  *    Rev 1.0   28 Apr 1994 19:17:30   thompson                   
  47.  
  48.  * Initial revision.
  49.  
  50.  * 
  51.  
  52.  *    Rev 1.0   20 Apr 1994 17:46:10   thompson                   
  53.  
  54.  * Initial revision.
  55.  
  56.  * Revision 1.2  1994/04/14  00:50:17  vriezen
  57.  * Updated copywrite, added ID and LOG and changed comments to indicate .cpp filename
  58.  *
  59.  *
  60.  * 
  61.  */
  62.  
  63. #include <iostream.h>
  64. #include <generic.h>
  65.  
  66. #define SMANIP(typ)    name2(smanip_, typ)
  67. #define SAPP(typ)    name2(sapply_, typ)
  68. #define IMANIP(typ)    name2(imanip_, typ)
  69. #define OMANIP(typ)    name2(omanip_, typ)
  70. #define IOMANIP(typ)    name2(iomanip_, typ)
  71. #define IAPP(typ)    name2(iapply_, typ)
  72. #define OAPP(typ)    name2(oapply_, typ)
  73. #define IOAPP(typ)    name2(ioapply_, typ)
  74.  
  75. #define IOMANIPdeclare(typ)                        \
  76. class SMANIP(typ) {                            \
  77.     ios& (*_fn)(ios&, typ);                        \
  78.     typ _ag;                            \
  79. public:                                    \
  80.     SMANIP(typ)(ios& (*_f)(ios&, typ), typ _a) : _fn(_f), _ag(_a) { }\
  81.     friend istream& operator>>(istream& _s, SMANIP(typ)& _f) {    \
  82.             (*_f._fn)(_s, _f._ag); return _s; }        \
  83.     friend ostream& operator<<(ostream& _s, SMANIP(typ)& _f) {    \
  84.             (*_f._fn)(_s, _f._ag); return _s; }        \
  85.     };                                \
  86. class SAPP(typ) {                            \
  87.     ios& (*_fn)(ios&, typ);                        \
  88. public:                                    \
  89.     SAPP(typ)(ios& (*_f)(ios&, typ)) : _fn(_f) { }            \
  90.     SMANIP(typ) operator()(typ _z) { return SMANIP(typ)(_fn, _z); }    \
  91.     };                                \
  92. class IMANIP(typ) {                            \
  93.     istream& (*_fn)(istream&, typ);                    \
  94.     typ _ag;                            \
  95. public:                                    \
  96.     IMANIP(typ)(istream& (*_f)(istream&, typ), typ _z ) :        \
  97.         _fn(_f), _ag(_z) { }                    \
  98.     friend istream& operator>>(istream& _s, IMANIP(typ)& _f) {    \
  99.         return(*_f._fn)(_s, _f._ag); }                \
  100.     };                                \
  101. class IAPP(typ) {                            \
  102.     istream& (*_fn)(istream&, typ);                    \
  103. public:                                    \
  104.     IAPP(typ)(istream& (*_f)(istream&, typ)) : _fn(_f) { }        \
  105.     IMANIP(typ) operator()(typ _z) {                \
  106.         return IMANIP(typ)(_fn, _z); }                \
  107.     };                                \
  108. class OMANIP(typ) {                            \
  109.     ostream& (*_fn)(ostream&, typ);                    \
  110.     typ _ag;                            \
  111. public:                                    \
  112.     OMANIP(typ)(ostream& (*_f)(ostream&, typ), typ _z ) :        \
  113.         _fn(_f), _ag(_z) { }                    \
  114.     friend ostream& operator<<(ostream& _s, OMANIP(typ)& _f) {    \
  115.         return(*_f._fn)(_s, _f._ag); }                \
  116.     };                                \
  117. class OAPP(typ) {                            \
  118.     ostream& (*_fn)(ostream&, typ);                    \
  119. public:                                    \
  120.     OAPP(typ)(ostream& (*_f)(ostream&, typ)) : _fn(_f) { }        \
  121.     OMANIP(typ) operator()(typ _z) {                \
  122.         return OMANIP(typ)(_fn, _z); }                \
  123.     };                                \
  124. class IOMANIP(typ) {                            \
  125.     iostream& (*_fn)(iostream&, typ);                \
  126.     typ _ag;                            \
  127. public:                                    \
  128.     IOMANIP(typ)(iostream& (*_f)(iostream&, typ), typ _z ) :    \
  129.         _fn(_f), _ag(_z) { }                    \
  130.     friend istream& operator>>(iostream& _s, IOMANIP(typ)& _f) {    \
  131.         return(*_f._fn)(_s, _f._ag); }                \
  132.     friend ostream& operator<<(iostream& _s, IOMANIP(typ)& _f) {    \
  133.         return(*_f._fn)(_s, _f._ag); }                \
  134.     };                                \
  135. class IOAPP(typ) {                            \
  136.     iostream& (*_fn)(iostream&, typ);                \
  137. public:                                    \
  138.     IOAPP(typ)(iostream& (*_f)(iostream&, typ)) : _fn(_f) { }    \
  139.     IOMANIP(typ) operator()(typ _z) { return IOMANIP(typ)(_fn, _z); }\
  140.     }
  141.  
  142.  
  143.  
  144. #pragma pack(__DEFALIGN)
  145. IOMANIPdeclare(int);
  146. IOMANIPdeclare(long);
  147. #pragma pack()
  148.  
  149. // set the conversion base to 0, 8, 10, or 16
  150. smanip_int     setbase(int _b);
  151.  
  152. // clear the flags bitvector according to the bits set in b
  153. smanip_long    resetiosflags(long _b);
  154.  
  155. // set the flags bitvector according to the bits set in b
  156. smanip_long    setiosflags(long _b);
  157.  
  158. // set fill character for padding a field
  159. smanip_int    setfill(int _f);
  160.  
  161. // set the floating-point precision to n digits
  162. smanip_int    setprecision(int _n);
  163.  
  164. // set the field width to n
  165. smanip_int    setw(int _n);
  166.  
  167. #endif /* _IOMANIP_H_ */
  168.